<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8" />
<title>E:before/E::before</title>
<meta name="description" content="CSS3参考手册之: E:before/E::before" />
<meta name="keywords" content="E:before, E::before, css3选择符, css3, css3参考手册" />
<meta name="author" content="Joy Du(飘零雾雨), dooyoe@gmail.com, www.doyoe.com" />
<meta name="robots" content="all" />
<!--[if lte IE 8]>
<script src="../../js/html5.js"></script>
<![endif]-->
<link rel="stylesheet" href="../../skin/article.css" />
</head>
<body>
<nav id="guide" class="g-mod">
	<div class="from">
		<a href="http://css.doyoe.com/" target="_blank">CSS3参考手册</a>
		<span>&#187;</span>
		<a href="../index.htm">选择符列表</a>
		<span>&#187;</span>
		<a href="index.htm" id="category" rel="selectors/pseudo-element" name="before">伪对象选择符</a>
		<span>&#187;</span>
	</div>
	<div class="to">
		<span class="label">相关内容：</span>
		<div class="g-combobox g-transition">
			<a href="?" class="g-transition target">
				<strong>其它伪对象选择符</strong>
				<span>选择其它项<!--[if lte IE 7]><ins>IE7 and earlier, Get to die</ins><![endif]--></span>
			</a>
			<div class="g-transition list">
				<ul>
					<!-- 插入分类快速导航 -->
				</ul>
			</div>
		</div>
	</div>
</nav>
<header id="hd">
	<section id="title" class="g-mod">
		<h1 class="tit">E:before/E::before</h1>
		<ul class="info">
			<li><strong>版本：CSS2/3</strong></li>
		</ul>
		<!-- 插入浏览器信息 -->
	</section>
</header>
<section id="bd">
	<section id="syntax" class="g-mod g-attr">
		<h2 class="tit">语法：</h2>
		<div class="cont">
			<p><strong>E:before/E::before</strong> { sRules }</p>
		</div>
	</section>
	<section id="intro" class="g-mod g-attr">
		<h2 class="tit">说明：</h2>
		<div class="cont">
			<strong>设置在对象前（依据对象树的逻辑结构）发生的内容。用来和<a href="../../properties/content/content.htm">content</a>属性一起使用，并且必须定义content属性</strong>
			<ul>
				<li>
					<p>CSS3将伪对象选择符(Pseudo-Element Selectors)前面的<em class="g-color-light">单个冒号(:)修改为双冒号(::)</em>用以区别伪类选择符(Pseudo-Classes Selectors)，但以前的写法仍然有效。</p>
					<p>即E:before可转化为E::before</p>
				</li>
			</ul>
		</div>
	</section>
	<section id="compatible" class="g-mod g-attr">
		<h2 class="tit">兼容性：</h2>
		<div class="cont">
			<ul class="support-type">
				<li><span class="support">浅绿</span> = 支持</li>
				<li><span class="unsupport">红色</span> = 不支持</li>
				<li><span class="partsupport">粉色</span> = 部分支持</li>
			</ul>
			<table class="g-data">
				<thead>
					<tr>
						<th>Selector</th>
						<th>IE</th>
						<th>Firefox</th>
						<th>Chrome</th>
						<th>Safari</th>
						<th>Opera</th>
						<th>iOS Safari</th>
						<th>Android Browser</th>
						<th>Android Chrome</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td rowspan="2"><strong>Basic Support</strong></td>
						<td class="unsupport">6.0-7.0</td>
						<td class="support">2.0-3.0 <sup><a href="#support2">#2</a></sup></td>
						<td class="support" rowspan="5">4.0+</td>
						<td class="support" rowspan="5">3.1+</td>
						<td class="support" rowspan="5">15.0+</td>
						<td class="support" rowspan="5">3.2+</td>
						<td class="support" rowspan="5">2.1+</td>
						<td class="support" rowspan="5">18.0+</td>
					</tr>
					<tr>
						<td class="support">8.0+</td>
						<td class="support">3.5+</td>
					</tr>
					<tr>
						<td rowspan="3">::before</td>
						<td class="unsupport">6.0-7.0</td>
						<td class="support">2.0-3.0 <sup><a href="#support2">#2</a></sup></td>
					</tr>
					<tr>
						<td class="partsupport">8.0 <sup><a href="#support1">#1</a></sup></td>
						<td class="support" rowspan="2">3.5+</td>
					</tr>
					<tr>
						<td class="support">9.0+</td>
					</tr>
					<tr>
						<td rowspan="2">应用动画</td>
						<td class="unsupport">6.0-9.0</td>
						<td class="unsupport">2.0-3.5</td>
						<td class="unsupport">4.0-25.0</td>
						<td class="unsupport">3.1-6.0</td>
						<td class="support" rowspan="2">15.0+</td>
						<td class="unsupport">3.2-6.1</td>
						<td class="unsupport">2.1-3.0</td>
						<td class="unsupport">18.0-25.0</td>
					</tr>
					<tr>
						<td class="support">10.0+ <sup><a href="#support3">#3</a></sup></td>
						<td class="support">4.0+</td>
						<td class="support">26.0+</td>
						<td class="support">6.1+</td>
						<td class="support">7.0+</td>
						<td class="support">4.0+</td>
						<td class="support">26.0+</td>
					</tr>
				</tbody>
			</table>
			<ol class="support-info">
				<li id="support1">本质上并不支持伪元素的双冒号(::)写法，而是忽略掉了其中的一个冒号，仍以单冒号来解析，所以等同变相支持了E::before。</li>
				<li id="support2">不支持设置属性position, float, list-style-*和一些display值，Firefox3.5开始取消这些限制。</li>
				<li id="support3">
					<p>IE10在使用伪元素动画有一个问题：</p>
					<div class="gquote">
						<p class="gquote-tit"><strong>例如：</strong></p>
						<blockquote class="gquote-cont"><code><xmp>.test:hover {}
.test:hover::before { /* 这时animation和transition才生效 */ }</xmp></code></blockquote>
							<p class="gquote-info">需要使用一个空的:hover来激活</p>
					</div>
				</li>
			</ol>
		</div>
	</section>
	<section id="example" class="g-mod g-attr">
		<h2 class="tit">示例：</h2>
		<div class="cont">
			<textarea cols="90" rows="10">
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8" />
<title>E::before_CSS参考手册_web前端开发参考手册系列</title>
<meta name="author" content="Joy Du(飘零雾雨), dooyoe@gmail.com, www.doyoe.com" />
<style>
p{position:relative;color:#f00;font-size:14px;font-size:0\9;*font-size:14px;}
p:before{position:absolute;background:#fff;color:#000;content:"如果你的能看到这段文字，说明你的浏览器只支持E:before";font-size:14px;}
p::before{position:absolute;background:#fff;color:#000;content:"如果你的能看到这段文字，说明你的浏览器支持E:before和E::before";font-size:14px;}
</style>
</head>
<body>
<p>Sorry, 你的浏览器不支持E:before和E::before</p>
</body>
</html>
			</textarea>
			<p><input type="button" value="运行" class="g-btn g-btn-sure" /></p>
		</div>
	</section>
</section>
<footer id="ft">
	<aside id="rights" class="g-mod">
		<!-- 插入浏览器及版权信息 -->
	</aside>
</footer>
<script src="../../js/jquery.js"></script>
<script src="../../js/inner.js"></script>
</body>
</html>